package com.mx.zb.mng.ctrl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.mx.zb.mng.bo.Agent;
import com.mx.zb.mng.bo.Operator;
import com.mx.zb.mng.bo.Role;
import com.mx.zb.mng.dao.AgentMapper;
import com.mx.zb.mng.dao.OperatorMapper;
import com.mx.zb.mng.dao.RoleMapper;
import com.mx.zb.mng.dao.TenantMapper;
import com.mx.zb.mng.utils.AjaxResult;
import com.mx.zb.mng.utils.context.ContextThread;
import com.mx.zb.mng.utils.ex.RestAnnotation;
/**
 * 登录后相关操作
 * @author 张衡
 *
 */
@RestController
@RestAnnotation
@RequestMapping("/a/login")
public class IndexRestCtrl {
	@Autowired
	AgentMapper agentMapper;
	
	@Autowired
	RoleMapper roleMapper;
	@Autowired
	OperatorMapper operatorMapper;
	@RequestMapping(value= {"/detail"}, method= {RequestMethod.GET})
	/**
	 * 登录后，显示个人信息
	 * @return
	 */
	public AjaxResult getDtail() {
		List<Object> list=new ArrayList<Object>();
		Operator operator=operatorMapper.selectByPrimaryKey(ContextThread.get().getOperatorId());
		Agent agent=agentMapper.selectByPrimaryKey(operator.getAgentId());
		Role role=new Role();
		if ("0".equals(operator.getRoleId())) {
			role.setName("系统默认管理员");
		}else {
			role=roleMapper.selectByPrimaryKey(operator.getRoleId());
		}	
		list.add(agent);
		list.add(operator);
		list.add(role);
		return new AjaxResult().success(list);
	}
	
}
